package cn.csc.module.member.convert.address;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.ip.core.utils.AreaUtils;
import cn.csc.module.member.api.address.dto.MemberAddressRespDTO;
import cn.csc.module.member.controller.app.address.vo.AppMemberAddressCreateReqVO;
import cn.csc.module.member.controller.app.address.vo.AppMemberAddressRespVO;
import cn.csc.module.member.controller.app.address.vo.AppMemberAddressUpdateReqVO;
import cn.csc.module.member.dal.dataobject.address.MemberAddressDO;
import org.mapstruct.Mapper;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 用户收件地址 Convert
 *
 * @author
 */
@Mapper
public interface MemberAddressConvert {

    MemberAddressConvert INSTANCE = Mappers.getMapper(MemberAddressConvert.class);

    MemberAddressDO convert(AppMemberAddressCreateReqVO bean);

    MemberAddressDO convert(AppMemberAddressUpdateReqVO bean);

    AppMemberAddressRespVO convert(MemberAddressDO bean);

    List<AppMemberAddressRespVO> convertList(List<MemberAddressDO> list);

    PageResult<AppMemberAddressRespVO> convertPage(PageResult<MemberAddressDO> page);

    MemberAddressRespDTO convert02(MemberAddressDO bean);

    @Named("convertAreaIdToAreaName")
    default String convertAreaIdToAreaName(Integer areaId) {
        return AreaUtils.format(areaId);
    }

}
